﻿using System;
using System.Collections.Generic;
using System.Data;
using DAL;
using Entities;
using Entities;

namespace BLL
{
    public class BLL_Customer
    {
        private DAL_Customer dal_Customer = new DAL_Customer();

        public DataTable Get_Customer_All()
        {
            return dal_Customer.Get_Customer_All();
        }

        public DataTable Get_Customer_Email_Phone(string pEmail,string pPhone)
        {
            return dal_Customer.Get_Customer_Email_Phone(pEmail,pPhone);
        }

        public bool DeleteCustomer(Int64 pID)
        {
            return dal_Customer.DeleteCustomer(pID);
        }

        public List<Customer> Lst_Customer(DataTable pdt)
        {
            List<Customer> lstReturn = new List<Customer>();
            if (pdt != null && pdt.Rows.Count > 0)
            {
                foreach (DataRow dr in pdt.Rows)
                {
                    Customer customer = new Customer();
                    customer.ID = (dr["ID"] == DBNull.Value ? 0 : Convert.ToInt64(dr["ID"]));
                    customer.FULLNAME = Convert.ToString(dr["FULLNAME"]);
                    customer.PHONE = Convert.ToString(dr["PHONE"]);
                    customer.EMAIL = Convert.ToString(dr["EMAIL"]);
                    customer.ADDRESS = Convert.ToString(dr["ADDRESS"]);
                    customer.DESCRIPTION = Convert.ToString(dr["DESCRIPTION"]);
                    customer.CITY = Convert.ToString(dr["CITY"]);
                    lstReturn.Add(customer);
                }
            }
            return lstReturn;
        }
    }
}
